#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef double db;
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+ch-'0'; ch=getchar(); }
	return x*f;
}
const int MAXN=3e4+10;
int n,f[MAXN][4],g[MAXN][4];
int main()
{
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	n=read();
	for(int i=1;i<=n;++i)
	{
		int x=read();
		f[i][1]=f[i-1][1]+1;
		f[i][2]=min(f[i-1][1],f[i-1][2])+2;
		f[i][3]=min(f[i-1][1],min(f[i-1][2],f[i-1][3]))+1;
		--f[i][x];
		g[i][3]=g[i-1][3]+1;
		g[i][2]=min(g[i-1][2],g[i-1][3])+1;
		g[i][1]=min(g[i-1][1],min(g[i-1][2],g[i-1][3]))+1;
		--g[i][x];
	}
	printf("%d\n",min(min(min(f[n][1],f[n][2]),f[n][3]),min(min(g[n][1],g[n][2]),g[n][3])));
	return 0;
}
